/// 设备比率
class RatioUtil {
  static RatioUtil? s;
  static RatioUtil getInstance() {
    s ??= RatioUtil();
    return s!;
  }

  late double designSize;
  late double size;

  /// 初始化设计尺寸
  static void init({
    required double size,
    required double designSize,
  }) {
    RatioUtil.s = null;
    var devicesGame = RatioUtil.getInstance();
    devicesGame.size = size;
    devicesGame.designSize = designSize;
  }

  //宽度比率
  double get ratioWidth {
    return size / designSize;
  }
}

extension SizeRatio on num {
  //屏幕宽比率
  double get gr {
    return this * RatioUtil.getInstance().ratioWidth;
  }
}
